package cn.dravenxiaokai.excel;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;

import java.io.File;

public class JxlReadExcel {
    /**
     * JXL解析Excel
     *
     * @param args
     * @author xiaokai
     * @date 2019-10-15 09:10:10
     */
    public static void main(String[] args) {
        try {
            // 创建workbook
            Workbook workbook = Workbook.getWorkbook(new File("d:/output/jxl_test.xls"));
            // 获取第一个工作表
            Sheet sheet1 = workbook.getSheet(0);
            // 获取数据
            for (int i = 0; i < sheet1.getRows(); i++) {
                for (int j = 0; j < sheet1.getColumns(); j++) {
                    Cell cell = sheet1.getCell(j, i);
                    System.out.print(cell.getContents() + " ");
                }
                System.out.println();
            }
            workbook.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
